<?php

namespace LaraPress\Config;

class ReduxFieldBuilder
{
    /**
     * 创建按钮组字段
     *
     * @param string $id 字段ID
     * @param string $title 标题
     * @param array $options 选项
     * @param mixed $default 默认值
     * @param bool $multi 是否多选
     * @param string $subtitle 副标题
     * @param array $required 依赖条件
     * @return array
     */
    public static function createButtonSet($id, $title, $options, $default = '', $multi = false, $subtitle = '', $desc = '', $required = [])
    {
        $field = [
            'id'      => $id,
            'type'    => 'button_set',
            'title'   => $title,
            'options' => $options,
            'default' => $default,
            'multi'   => $multi,
        ];

        if ($subtitle) {
            $field['subtitle'] = $subtitle;
        }

        if ($desc) {
            $field['desc'] = $desc;
        }

        if (!empty($required)) {
            $field['required'] = $required;
        }

        return $field;
    }
}
